<script src="{$addons_static}/jquery3.min.js"></script>
<script src="{$addons_static}/wangEditor.min.js"></script>
<style>
    .ck-editor__editable {
        min-height: 300px; !important;
        min-width: 100% !important;
    }

    .ck-editor{
        min-width: 300px;
    }

    .select2-container--default .select2-selection--multiple .select2-selection__choice {
        background-color: #007bff;
        border-color: #006fe6;
        padding: 1px 10px;
        color: #fff;
    }

    .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
        margin-right: 5px;
        color: rgba(255, 255, 255, .7);
    }
</style>
<form role="form" class="epii" method="post" data-form="1" action="{url hospital add_edit }">

    <div class="form-group">
        <label>名称：</label>
        <input type="text" class="form-control" name="r[name]" value="{? $info.name}" required
               placeholder="请输入医院名称">
    </div>
    <div class="form-group">
        <label>联系电话：</label>
        <input type="text" class="form-control" name="r[phone]" value="{? $info.phone}" required
               placeholder="请输入医院联系电话">
    </div>
<!--    <div class="form-group">-->
<!--        <label>法人：</label>-->
<!--        <input type="text" class="form-control" name="r[legal_person_name]" value="{? $info.legal_person_name}" required-->
<!--               placeholder="请输入法人姓名">-->
<!--    </div>-->
<!--    <div class="form-group">-->
<!--        <label>法人电话：</label>-->
<!--        <input type="text" class="form-control" name="r[legal_person_phone]" value="{? $info.legal_person_phone}" required-->
<!--               placeholder="请输入法人电话">-->
<!--    </div>-->
    <div class="form-group">
        <label>地址：</label>
        <input type="text" class="form-control" name="r[address]" value="{? $info.address}" required
               placeholder="请输入中医院地址">
    </div>
    <div class="form-group">
        <label>类型：</label>
        <select class="selectpicker" name="r[type]" id="">
            {:options,$hospital_type,$info.type}
        </select>
    </div>
    <div class="form-group">
        <label>上级医院：</label>
        <select class="selectpicker" name="r[pid]" id="">
            {:options,$hospital_parent,$info.pid}
        </select>
    </div>
    <div class="form-group">
        <label class="control-label">logo图:</label>
        <div style="width: 60%"
             data-upload-preview="1"
             data-multiple="1"
             data-input-id="logo_id"
             data-maxcount="1"
             data-mimetype="jpg,gif,png,jpeg"
             data-maxsize="20480kb"
             data-url="{url file upload}"

             data-upload-success=""
        ></div>
    </div>
    <div class="form-group hide">
        <label class="control-label hide">图片存储地址:</label>
        <input type="text" class="form-control" readonly id="logo_id" name="r[logo]" value="{? $info.logo}"   data-src="{? $info.logo}">
    </div>
    <div class="form-group">
        <label class="control-label">轮播图:</label>
        <div style="width: 60%"
             data-upload-preview="1"
             data-multiple="1"
             data-input-id="img_id"
             data-maxcount="5"
             data-mimetype="jpg,gif,png,jpeg"
             data-maxsize="20480kb"
             data-url="{url file upload}"

             data-upload-success=""
        ></div>
    </div>
    <div class="form-group hide">
        <label class="control-label hide">图片存储地址:</label>
        <input type="text" class="form-control" readonly id="img_id" name="r[imgs]" value="{? $info.imgs}"   data-src="{? $info.imgs}">
    </div>
    <div class="form-group">
        <label>状态：</label>
        <select class="selectpicker" name="r[status]" id="">
            {:options,$status,$info.status?1}
        </select>
    </div>
<!--    <div class="form-group">-->
<!--        <label>简介：</label>-->
<!--        <textarea class="form-control" name="r[desc]" id="" cols="20" rows="5">{? $info.desc}</textarea>-->
<!--    </div>-->


    <div class="form-group">
        <label>内容：</label>
        <div class="form-control" style="width: 70%" id="div1">
            {? $info.desc}
        </div>
        <textarea id="text1" name="r[desc]" style="display: none">{? $info.desc}</textarea>
    </div>
    <input type="hidden" name="id" value="{$id?0}">
    <div class="form-footer">
        <button type="submit" class="btn btn-primary">提交</button>
    </div>
</form>
<script>
    function upload_success() {
        var src=$('.epii-upload-file-icon>img').attr('src');
        console.log(src,'src')
        $('input[name="r[logo]"]').val(src)
    }
    const E = window.wangEditor
    const editor = new E('#div1')
    const $text1 = $('#text1')
    editor.config.onchange = function (html) {
        // 第二步，监控变化，同步更新到 textarea
        $text1.val(html)
    }
    editor.create()
    // 第一步，初始化 textarea 的值
    $text1.val(editor.txt.html())

</script>
